package com.shujia.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Map;


@Component
@RestController
@ConfigurationProperties(prefix = "user")
public class ArgsController {
    private Integer userId;
    private String userName;
    private Integer userAge;
    private String userSex;

    public void setUserId(Integer userId) {
        this.userId = userId;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public void setUserAge(Integer userAge) {
        this.userAge = userAge;
    }

    public void setUserSex(String userSex) {
        this.userSex = userSex;
    }

    //    //测试基本数据类型的传值
//    @Value("${id}")
//    private Integer id;
//    @Value("${flag}")
//    private Boolean flag;
//    @Value("${name}")
//    private String name;
//    @Value("${price}")
//    private Double price;
//    @Value("${bir}")
//    private Date bir;
//    @Value("${ss}")
//    private String[] ss;
//    @Value("${list}")
//    private List<String> list;
//    @Value("#{${map}}")
//    private Map<String, String> map;

//    @RequestMapping("args")
//    public String argsFun() {
//        System.out.println("姓名：" + name);
//        System.out.println("flag：" + flag);
//        System.out.println("id：" + id);
//        System.out.println("price：" + price);
//        System.out.println("bir：" + bir);
//
//        return "测试参数的接口  " + name + "," + flag + "," + id +
//                "," + price + "," + bir + "," + Arrays.toString(ss) + "," + list + "," + map;
//    }

    @RequestMapping("args2")
    public String argsFun2(){
        return "测试参数的接口  " + userId + "," + userName + "," + userAge +
                "," + userSex;
    }


}
